var request = require('request');
var adUrl = require('../../app.config/env/adUrl.config');
module.exports = {
    getBanList:getBanList,
    removeBanName:removeBanName,
    addBanName:addBanName,
    isBan:isBan
}

function getBanList(){
    var url = adUrl.adUrl+adUrl.getBanList;
    global.banList=[];
    request.get({url:url},function(err,httpResponse,body){
        var result = JSON.parse(body);
        // console.log("result:"+result.data.length);
        global.banList=result.data;

    });

}

function removeBanName(val) {
    for(var i in global.banList){
        if(global.banList[i]==val){
            global.banList.splice(i,1);
            break;
        }
    }
}

function addBanName(val){
    global.banList.push(val);
}

function isBan(val){
    for(var i in global.banList){
        if(global.banList[i]==val){
            return true;
        }
    }
    return false;
}